package com.kadron.order;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.kadron.datamodel.KModel;
import com.kadron.entity.Order;

public class KOrderModel implements KModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3731519539731997584L;

	private Order order;
	private List<OrderItemData> items = new ArrayList<OrderItemData>();
	private BigDecimal total;
	
	private KOrderModel() {
		super();
	}
	
	public KOrderModel(Order order) {
		this();
		this.order = order;
	}

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	public List<OrderItemData> getItems() {
		return items;
	}

	public void setItems(List<OrderItemData> items) {
		this.items = items;
	}

	@Override
	public long getId() {
		return order.getId();
	}

	public BigDecimal getTotal() {
		return total;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((order == null) ? 0 : order.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		KOrderModel other = (KOrderModel) obj;
		if (order == null) {
			if (other.order != null)
				return false;
		} else if (!order.equals(other.order))
			return false;
		return true;
	}
	
}
